snapshot: Add gtk_snapshot_append_border()
authorBenjamin Otte <otte@redhat.com>
Thu, 21 Feb 2019 01:11:13 +0000 (02:11 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 21 Feb 2019 18:47:28 +0000 (19:47 +0100)
This is adding functions for the remaining render nodes.

docs/reference/gtk/gtk4-sections.txt
gsk/gskrendernodeimpl.c
gtk/gtkrenderborder.c
gtk/gtksnapshot.c
gtk/gtksnapshot.h

index bbe287b7d40f388c7764c08b00c612e8c3879728..bb39c8f935b817746b81c90040ed55d19cdd7730 100644 (file)
@@ -4409,6 +4409,9 @@ gtk_snapshot_append_cairo
 gtk_snapshot_append_texture
 gtk_snapshot_append_color
 gtk_snapshot_append_layout
+gtk_snapshot_append_linear_gradient
+gtk_snapshot_append_repeating_linear_gradient
+gtk_snapshot_append_border
 gtk_snapshot_render_background
 gtk_snapshot_render_frame
 gtk_snapshot_render_focus
index 65c8e33332cf0b7dc7bc12229011bbbdcbc33578..aa72646065bc2cf8aed4a355f1295222e1c73d8b 100644 (file)
@@ -712,9 +712,10 @@ gsk_border_node_peek_colors (GskRenderNode *node)
 /**
  * gsk_border_node_new:
  * @outline: a #GskRoundedRect describing the outline of the border
- * @border_width: the stroke width of the border on the top, right, bottom and
- *     left side respectively.
- * @border_color: the color used on the top, right, bottom and left side.
+ * @border_width: (array fixed-size=4): the stroke width of the border on
+ *     the top, right, bottom and left side respectively.
+ * @border_color: (array fixed-size=4): the color used on the top, right,
+ *     bottom and left side.
  *
  * Creates a #GskRenderNode that will stroke a border rectangle inside the
  * given @outline. The 4 sides of the border can have different widths and
index 08a05f692fdf990c3ab4b7e300df017a5b2fef67..d39c736ff80912e37bd0e951ad17a2ec764b8840 100644 (file)
@@ -342,10 +342,6 @@ snapshot_frame_fill (GtkSnapshot          *snapshot,
                      const GdkRGBA         colors[4],
                      guint                 hidden_side)
 {
-  GskRoundedRect offset_outline;
-  GskRenderNode *node;
-  int off_x, off_y;
-
   if (hidden_side)
     {
       GdkRGBA real_colors[4];
@@ -363,13 +359,7 @@ snapshot_frame_fill (GtkSnapshot          *snapshot,
       return;
     }
 
-  gtk_snapshot_get_offset (snapshot, &off_x, &off_y);
-  gsk_rounded_rect_init_copy (&offset_outline, outline);
-  gsk_rounded_rect_offset (&offset_outline, off_x, off_y);
-  
-  node = gsk_border_node_new (&offset_outline, border_width, colors);
-  gtk_snapshot_append_node_internal (snapshot, node);
-  gsk_render_node_unref (node);
+  gtk_snapshot_append_border (snapshot, outline, border_width, colors);
 }
 
 static void
index b862e5a7a6fdb23c809f45f8c9fb324ec710dca8..1be41ad138ea6c27343cccd875e4f087666c3955 100644 (file)
@@ -1558,3 +1558,39 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot            *snapshot,
   gtk_snapshot_append_node_internal (snapshot, node);
   gsk_render_node_unref (node);
 }
+
+/**
+ * gtk_snapshot_append_border:
+ * @snapshot: a #GtkSnapshot
+ * @outline: a #GskRoundedRect describing the outline of the border
+ * @border_width: (array fixed-size=4): the stroke width of the border on
+ *     the top, right, bottom and left side respectively.
+ * @border_color: (array fixed-size=4): the color used on the top, right,
+ *     bottom and left side.
+ *
+ * Appends a stroked border rectangle inside the given @outline. The
+ * 4 sides of the border can have different widths and colors.
+ **/
+void
+gtk_snapshot_append_border (GtkSnapshot          *snapshot,
+                            const GskRoundedRect *outline,
+                            const float           border_width[4],
+                            const GdkRGBA         border_color[4])
+{
+  GskRenderNode *node;
+  GskRoundedRect real_outline;
+  float scale_x, scale_y, dx, dy;
+
+  g_return_if_fail (snapshot != NULL);
+  g_return_if_fail (outline != NULL);
+  g_return_if_fail (border_width != NULL);
+  g_return_if_fail (border_color != NULL);
+
+  gtk_snapshot_ensure_affine (snapshot, &scale_x, &scale_y, &dx, &dy);
+  gtk_rounded_rect_scale_affine (&real_outline, outline, scale_x, scale_y, dx, dy);
+
+  node = gsk_border_node_new (&real_outline, border_width, border_color);
+
+  gtk_snapshot_append_node_internal (snapshot, node);
+  gsk_render_node_unref (node);
+}
index 1ee801a71b275b13675e1562ac5295814b6eb540..1f61d7a214d02862dc0b0354ec37f6ca99888e34 100644 (file)
@@ -141,6 +141,11 @@ void            gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot
                                                                const graphene_point_t *end_point,
                                                                const GskColorStop     *stops,
                                                                gsize                   n_stops);
+GDK_AVAILABLE_IN_ALL
+void            gtk_snapshot_append_border              (GtkSnapshot            *snapshot,
+                                                         const GskRoundedRect   *outline,
+                                                         const float             border_width[4],
+                                                         const GdkRGBA           border_color[4]);
 /* next function implemented in gskpango.c */
 GDK_AVAILABLE_IN_ALL
 void            gtk_snapshot_append_layout              (GtkSnapshot            *snapshot,